"""
老师逻辑接口层
"""

from db import models


# 老师查看教授课程接口函数
def check_teach_course_interface(teacher):
    teacher_obj = models.Teacher.select(teacher)
    return teacher_obj.check_teach_course()


# 老师选择教授课程函数接口函数
def select_teach_course_interface(course_name, teacher):
    # 1. 检查老师是否已经选过该课程
    teacher_obj = models.Teacher.select(teacher)

    # 2. 如果选过则直接退出
    if course_name in teacher_obj.course_list:
        return "该课程已经选过！"

    # 2. 如果没有选过则选择课程
    teacher_obj.select_teach_course(course_name)
    return f"[{teacher}] 老师选择教授 [{course_name}] 课程成功！"


# 老师查看课程下学生接口函数
def check_stu_of_course_interface(course_name, teacher):
    teacher_obj = models.Teacher.select(teacher)
    return teacher_obj.check_stu_of_course(course_name)


# 老师修改学生成绩接口函数
def modify_stu_score_interface(select_course, student, score, teacher):
    teacher_obj = models.Teacher.select(teacher)
    
    teacher_obj.modify_stu_score(select_course, student, score)
    return f"[{teacher}] 修改 [{student}] 学生的 [{select_course}] 成绩为 [{score}] 分！"